Page({
  data: {
    width:0,              // 设备宽度
    margin:0,             // 回收值  
    markers: [],
    polyline: [],
    longitude: "",
    latitude: "",
    logistics_id: 0
  },
  regionchange(e) {
    console.log(e.type)
  },
  markertap(e) {
    console.log(e.detail.markerId)
  },
  controltap(e) {
    console.log(e.detail.controlId)
  },
  onLoad: function(options) {
    var that = this;
    wx.getLocation({
      success: function (res) {
        console.log("位置", res)
        that.setData({
          latitude: res.latitude,
          longitude: res.longitude,
          markers: [{
            latitude: res.latitude,
            longitude: res.longitude
          }],
        })
      },
    })
    this.setData({
      logistics_id: options.logistics_id
    });
    this.detailLogistics();


    let self = this, width = wx.getStorageSync('SystemInfo')['windowWidth'],data={};
    // 获取设备信息
    data.width=width-60;
    data.margin=data.width/2;
    self.setData(data)

    
  },

  /**
   * 打电话
   */
  callPhone(){
    wx.makePhoneCall({
      phoneNumber: this.data.employee_mobile,
    })
  },

    /**
   * 复制运单号
   */
  copyLogisticsNo(e){
    let logistics_no = e.currentTarget.dataset.logisticsno;
    wx.setClipboardData({
      data: logistics_no
    })
  },

  /**
   * 托运单详情
   */
  detailLogistics: function(){
    wx.$api.detailLogistics({ logistics_id: this.data.logistics_id}).then(res => {
      if(res.data.code != 200)  return  wx.$Toast(res.data.msg);
      let get_data = res.data.data;
      this.setData({
        logistics_no: get_data.logistics_no,
        depart_region_name: get_data.depart_region_name,
        arrive_region_name: get_data.arrive_region_name,
        post_communicate_name: get_data.post_communicate_name,
        receive_communicate_name: get_data.receive_communicate_name,
        employee_name: get_data.employee_name,
        employee_mobile: get_data.employee_mobile,
        company_name: get_data.company_name,
        goods_type: get_data.goods_type,
        weight: get_data.weight,
        expected_money: get_data.expected_money,
        member_picture: get_data.member_picture,
        employee_picture: get_data.employee_picture,
        logistics_status: get_data.logistics_status,
        employee_picture: get_data.employee_picture,
        markers: get_data.map.markers,
        polyline: get_data.map.polyline,
        post_time: get_data.post_time,
        type: get_data.company.type,
        post_communicate_address: get_data.post_communicate_address,
        receive_communicate_address: get_data.receive_communicate_address
      });


    });

  }


})